//
//  MoreManager.m
//  takeout
//
//  Created by Derekc on 12-4-16.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "MoreManager.h"
#import "Constants.h"
#import "ResolveXML.h"

@implementation MoreManager

-(BOOL) sendErrorReport:(NSString *) desc{
    return [self getResponse:[NSString stringWithFormat:SERVICE_ERROR_REPORT,desc]];
}
-(BOOL) sendFeedBack:(NSString *) desc{
    return [self getResponse:[NSString stringWithFormat:SERVICE_FEEDBACK,desc]];    
}
-(BOOL) getResponse:(NSString *) url{
    ResolveXML *resolveXML=[[ResolveXML alloc]init];
    NSString *URIString = [NSString stringWithFormat:SERVICE_DOMAIN, url];
    CUSTOM_LOG(URIString);
    GDataXMLDocument *doc=[resolveXML getXMLDocument:URIString];
    [resolveXML release];
    NSArray *children = [doc.rootElement children]; 
    NSString *result = [(GDataXMLElement*)[children objectAtIndex:0] stringValue];
    if ([result isEqualToString:SUCCESS_MSG]) {
        return YES;
    }
    return NO;
}

-(Version *) getVersion{
    ResolveXML *resolveXML=[[ResolveXML alloc]init];
    NSString *URIString = [NSString stringWithFormat:SERVICE_DOMAIN, SERVICE_GETVERSION];
    CUSTOM_LOG(URIString);
    GDataXMLDocument *doc=[resolveXML getXMLDocument:URIString];
    [resolveXML release];
    NSArray *children = [doc.rootElement children]; 
    Version *version = [[Version alloc] init];
    version.number = [[(GDataXMLElement*)[children objectAtIndex:0] stringValue] floatValue];
    version.description = [(GDataXMLElement*)[children objectAtIndex:1] stringValue];
    NSLog(@"%@",version.description);
    [version release];
    return version;
}

@end
